package controllers;

import play.*;
import play.mvc.*;

import java.sql.SQLException;
import java.util.*;

import models.*;

import siena.*;

public class Application extends Controller {

	@Index("user_index")
	public User user;
	
    public static void index() throws SQLException, ClassNotFoundException {
    	User people=null;
    	try{
    		people = User.all().filter("firstName", "Mark").get();
        	if(people!=null){
        		renderArgs.put("id",people.id);
        		renderArgs.put("userName",people.userName);
        		renderArgs.put("lastName",people.lastName);
        	}else{
        		renderArgs.put("id","Valor nulo");
        	}
    	}catch(SienaException e){
    		UseDatabase.crear();
    		renderArgs.put("id","creando la tabla");
    	}
    	User newPeople = new User();
    	newPeople.firstName="Mark";
    	newPeople.userName="lalala";
    	newPeople.lastName= "lololo";
    	newPeople.insert();
    	
    	renderArgs.put("newUserName",newPeople.userName);
    	renderArgs.put("newLastName",newPeople.lastName);
        render();
    }

}